using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.DXErrorProvider;
using DevExpress.XtraLayout;
using DevExpress.XtraLayout.Utils;
using Common.Class;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Common.Base
{
	public class XucBaseAdd26 : XucBase
	{
		private IContainer components = null;
		protected TextEdit txtNAME;
		protected TextEdit txtID;
		protected ImageCollection imageCollection2;
		protected DXErrorProvider Err;
		protected SimpleButton btnSave;
		protected SimpleButton btnCancel;
		protected SimpleButton btnSaveNew;
		protected LayoutControlItem liId;
		protected LayoutControlItem liName;
		protected LayoutControl lcMain;
		protected LayoutControlGroup lgMain;
		protected LayoutControlItem liSave;
		protected LayoutControlItem liCancel;
		protected LayoutControlItem liSaveNew;
		public event ButtonClickEventHander CancelClick;
		public XucBaseAdd26()
		{
			this.InitializeComponent();
			this.Init();
		}
		public void RaiseCancelClickEventHander()
		{
			if (this.CancelClick != null)
			{
				this.CancelClick(this);
			}
		}
		protected virtual void Init()
		{
			this.ReLoad();
		}
		public void SetData(string id)
		{
			this.txtID.Text = id;
			this.txtNAME.Focus();
			this.Add();
		}
		protected bool Check()
		{
			return true;
		}
		public void Save()
		{
			if (this.txtID.ErrorText != string.Empty | this.txtID.Text == string.Empty)
			{
				XtraMessageBox.Show((this.txtID.ErrorText.Length == 0) ? "Dữ liệu của ô này không được bỏ trống." : this.txtID.ErrorText, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.txtID.Focus();
			}
			else
			{
				if (this.txtNAME.ErrorText != string.Empty | this.txtNAME.Text == string.Empty)
				{
					XtraMessageBox.Show((this.txtNAME.ErrorText.Length == 0) ? "Dữ liệu của ô này không được bỏ trống." : this.txtNAME.ErrorText, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					this.txtNAME.Focus();
				}
				else
				{
					if (this.Check())
					{
						switch (this.MStatus)
						{
						case Actions.Add:
							this.UcSave();
							break;
						case Actions.Update:
							this.UcUpdate();
							break;
						}
					}
				}
			}
		}
		public void Delete()
		{
			this.UcDelete();
		}
		public void ReLoad()
		{
		}
		protected virtual string UcSave()
		{
			return string.Empty;
		}
		protected virtual string UcUpdate()
		{
			return string.Empty;
		}
		protected virtual string UcDelete()
		{
			return string.Empty;
		}
		private void TxtIDLeave(object sender, EventArgs e)
		{
			TextEdit textEdit = (TextEdit)sender;
			if (this.MStatus != Actions.None)
			{
				if (textEdit.Text == string.Empty)
				{
					this.Err.SetError(textEdit, "Vui lòng nhập thông tin." + this.Text);
				}
			}
		}
		protected virtual void TxtIDEditValueChanged(object sender, EventArgs e)
		{
		}
		protected virtual void TxtIDKeyDown(object sender, KeyEventArgs e)
		{
		}
		private void TxtNameLeave(object sender, EventArgs e)
		{
			TextEdit textEdit = (TextEdit)sender;
			if (this.MStatus != Actions.None)
			{
				if (textEdit.Text == string.Empty)
				{
					this.Err.SetError(textEdit, "Vui lòng nhập thông tin." + this.Text);
				}
				if (string.IsNullOrEmpty(this.txtID.Text))
				{
					if (!string.IsNullOrEmpty(this.txtNAME.Text))
					{
						this.txtID.Text = base.GenerateCode(this.txtNAME.Text);
					}
				}
			}
		}
		private void TxtNameEditValueChanged(object sender, EventArgs e)
		{
			TextEdit textEdit = (TextEdit)sender;
			if (this.MStatus != Actions.None)
			{
				if (textEdit.ErrorText != string.Empty)
				{
					this.Err.SetError(textEdit, string.Empty);
				}
			}
		}
		protected void BtnSaveClick(object sender, EventArgs e)
		{
			this.MCloseOrNew = CloseOrNew.Close;
			this.Save();
		}
		protected void BtnCancelClick(object sender, EventArgs e)
		{
			this.RaiseCancelClickEventHander();
		}
		protected void BtnSaveKeyDown(object sender, KeyEventArgs e)
		{
			this.BtnSaveClick(this.btnSave, e);
		}
		protected void BtnCancelKeyDown(object sender, KeyEventArgs e)
		{
			this.BtnCancelClick(this.btnCancel, e);
		}
		private void BtnSaveNewClick(object sender, EventArgs e)
		{
			this.Save();
			if (this.MCloseOrNew == CloseOrNew.New)
			{
				this.MCloseOrNew = CloseOrNew.New;
				this.txtID.Properties.ReadOnly = false;
				this.MStatus = Actions.Add;
				this.txtID.Focus();
				this.Add();
			}
		}
		public virtual void Add()
		{
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.components = new Container();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(XucBaseAdd26));
			SuperToolTip superToolTip = new SuperToolTip();
			ToolTipItem toolTipItem = new ToolTipItem();
			SuperToolTip superToolTip2 = new SuperToolTip();
			ToolTipItem toolTipItem2 = new ToolTipItem();
			this.txtNAME = new TextEdit();
			this.lcMain = new LayoutControl();
			this.btnCancel = new SimpleButton();
			this.imageCollection2 = new ImageCollection(this.components);
			this.btnSaveNew = new SimpleButton();
			this.txtID = new TextEdit();
			this.btnSave = new SimpleButton();
			this.lgMain = new LayoutControlGroup();
			this.liId = new LayoutControlItem();
			this.liName = new LayoutControlItem();
			this.liSave = new LayoutControlItem();
			this.liSaveNew = new LayoutControlItem();
			this.liCancel = new LayoutControlItem();
			this.Err = new DXErrorProvider(this.components);
			((ISupportInitialize)this.txtNAME.Properties).BeginInit();
			((ISupportInitialize)this.lcMain).BeginInit();
			this.lcMain.SuspendLayout();
			((ISupportInitialize)this.imageCollection2).BeginInit();
			((ISupportInitialize)this.txtID.Properties).BeginInit();
			((ISupportInitialize)this.lgMain).BeginInit();
			((ISupportInitialize)this.liId).BeginInit();
			((ISupportInitialize)this.liName).BeginInit();
			((ISupportInitialize)this.liSave).BeginInit();
			((ISupportInitialize)this.liSaveNew).BeginInit();
			((ISupportInitialize)this.liCancel).BeginInit();
			((ISupportInitialize)this.Err).BeginInit();
			base.SuspendLayout();
			this.txtNAME.Location = new Point(60, 31);
			this.txtNAME.Name = "txtNAME";
			this.txtNAME.Size = new Size(319, 20);
			this.txtNAME.StyleController = this.lcMain;
			this.txtNAME.TabIndex = 3;
			this.txtNAME.EditValueChanged += new EventHandler(this.TxtNameEditValueChanged);
			this.txtNAME.Leave += new EventHandler(this.TxtNameLeave);
			this.lcMain.Controls.Add(this.txtNAME);
			this.lcMain.Controls.Add(this.btnCancel);
			this.lcMain.Controls.Add(this.btnSaveNew);
			this.lcMain.Controls.Add(this.txtID);
			this.lcMain.Controls.Add(this.btnSave);
			this.lcMain.Dock = DockStyle.Fill;
			this.lcMain.Location = new Point(0, 0);
			this.lcMain.Name = "lcMain";
			this.lcMain.Root = this.lgMain;
			this.lcMain.Size = new Size(386, 452);
			this.lcMain.TabIndex = 38;
			this.lcMain.Text = "layoutControl1";
			this.btnCancel.ImageIndex = 6;
			this.btnCancel.ImageList = this.imageCollection2;
			this.btnCancel.Location = new Point(60, 107);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new Size(319, 22);
			this.btnCancel.StyleController = this.lcMain;
			this.btnCancel.TabIndex = 36;
			this.btnCancel.Text = "Bỏ qua";
			this.btnCancel.Click += new EventHandler(this.BtnCancelClick);
			this.btnCancel.KeyDown += new KeyEventHandler(this.BtnCancelKeyDown);
			this.imageCollection2.ImageStream = (ImageCollectionStreamer)componentResourceManager.GetObject("imageCollection2.ImageStream");
			this.btnSaveNew.ImageIndex = 0;
			this.btnSaveNew.ImageList = this.imageCollection2;
			this.btnSaveNew.Location = new Point(60, 81);
			this.btnSaveNew.Name = "btnSaveNew";
			this.btnSaveNew.Size = new Size(319, 22);
			this.btnSaveNew.StyleController = this.lcMain;
			toolTipItem.Text = "Ctrl+Shift +S";
			superToolTip.Items.Add(toolTipItem);
			this.btnSaveNew.SuperTip = superToolTip;
			this.btnSaveNew.TabIndex = 37;
			this.btnSaveNew.Text = "Lưu && Thêm";
			this.btnSaveNew.Click += new EventHandler(this.BtnSaveNewClick);
			this.txtID.Location = new Point(60, 7);
			this.txtID.Name = "txtID";
			this.txtID.Size = new Size(319, 20);
			this.txtID.StyleController = this.lcMain;
			this.txtID.TabIndex = 1;
			this.txtID.EditValueChanged += new EventHandler(this.TxtIDEditValueChanged);
			this.txtID.Leave += new EventHandler(this.TxtIDLeave);
			this.txtID.KeyDown += new KeyEventHandler(this.TxtIDKeyDown);
			this.btnSave.ImageIndex = 0;
			this.btnSave.ImageList = this.imageCollection2;
			this.btnSave.Location = new Point(60, 55);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new Size(319, 22);
			this.btnSave.StyleController = this.lcMain;
			toolTipItem2.Text = "Ctrl+S\r\n";
			superToolTip2.Items.Add(toolTipItem2);
			this.btnSave.SuperTip = superToolTip2;
			this.btnSave.TabIndex = 35;
			this.btnSave.Text = "Lưu && Đóng";
			this.btnSave.Click += new EventHandler(this.BtnSaveClick);
			this.btnSave.KeyDown += new KeyEventHandler(this.BtnSaveKeyDown);
			this.lgMain.CustomizationFormText = "lgMain";
			this.lgMain.EnableIndentsWithoutBorders = DefaultBoolean.True;
			this.lgMain.GroupBordersVisible = false;
			this.lgMain.Items.AddRange(new BaseLayoutItem[]
			{
				this.liId,
				this.liName,
				this.liSave,
				this.liSaveNew,
				this.liCancel
			});
			this.lgMain.Location = new Point(0, 0);
			this.lgMain.Name = "lgMain";
			this.lgMain.Padding = new DevExpress.XtraLayout.Utils.Padding(5, 5, 5, 5);
			this.lgMain.Size = new Size(386, 452);
			this.lgMain.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0);
			this.lgMain.Text = "lgMain";
			this.lgMain.TextVisible = false;
			this.liId.Control = this.txtID;
			this.liId.CustomizationFormText = "Mã";
			this.liId.Location = new Point(0, 0);
			this.liId.Name = "liId";
			this.liId.Size = new Size(376, 24);
			this.liId.Text = "Mã";
			this.liId.TextSize = new Size(49, 13);
			this.liName.Control = this.txtNAME;
			this.liName.CustomizationFormText = "Tên";
			this.liName.Location = new Point(0, 24);
			this.liName.Name = "liName";
			this.liName.Size = new Size(376, 24);
			this.liName.Text = "Tên";
			this.liName.TextSize = new Size(49, 13);
			this.liSave.Control = this.btnSave;
			this.liSave.CustomizationFormText = "layoutControlItem1";
			this.liSave.Location = new Point(0, 48);
			this.liSave.Name = "liSave";
			this.liSave.Size = new Size(376, 26);
			this.liSave.Text = "liSave";
			this.liSave.TextSize = new Size(49, 13);
			this.liSaveNew.Control = this.btnSaveNew;
			this.liSaveNew.CustomizationFormText = "layoutControlItem2";
			this.liSaveNew.Location = new Point(0, 74);
			this.liSaveNew.Name = "liSaveNew";
			this.liSaveNew.Size = new Size(376, 26);
			this.liSaveNew.Text = "liSaveNew";
			this.liSaveNew.TextSize = new Size(49, 13);
			this.liCancel.Control = this.btnCancel;
			this.liCancel.CustomizationFormText = "layoutControlItem3";
			this.liCancel.Location = new Point(0, 100);
			this.liCancel.Name = "liCancel";
			this.liCancel.Size = new Size(376, 342);
			this.liCancel.Text = "liCancel";
			this.liCancel.TextSize = new Size(49, 13);
			this.Err.ContainerControl = this;
			base.AutoScaleDimensions = new SizeF(6f, 13f);
			base.AutoScaleMode = AutoScaleMode.Font;
			base.Controls.Add(this.lcMain);
			base.Name = "XucBaseAdd26";
			base.Size = new Size(386, 452);
			((ISupportInitialize)this.txtNAME.Properties).EndInit();
			((ISupportInitialize)this.lcMain).EndInit();
			this.lcMain.ResumeLayout(false);
			((ISupportInitialize)this.imageCollection2).EndInit();
			((ISupportInitialize)this.txtID.Properties).EndInit();
			((ISupportInitialize)this.lgMain).EndInit();
			((ISupportInitialize)this.liId).EndInit();
			((ISupportInitialize)this.liName).EndInit();
			((ISupportInitialize)this.liSave).EndInit();
			((ISupportInitialize)this.liSaveNew).EndInit();
			((ISupportInitialize)this.liCancel).EndInit();
			((ISupportInitialize)this.Err).EndInit();
			base.ResumeLayout(false);
		}
	}
}
